<template>
  <el-dialog :title="pdfInfo.title" :visible.sync="pdfInfo.show" @close="cancel" append-to-body width="90%" style="margin-top: -40px">
    <iframe v-if="pdfInfo.show" ref="pdfCotainer" :src="pdfData" style="width: 100%; height: 90vh"></iframe>
  </el-dialog>
</template>

<script>
import pdf from 'vue-pdf'
import { getFileStream } from '@/api/gd/wjglfl'
export default {
  name: 'queryPdf',
  components: { pdf },
  props: {
    pdfInfo: {
      type: Object
    }
  },
  data() {
    return {
      pdfData: null,
    };
  },
  async created() {
    await this.init();
  },
  methods: {
    async init() {
      await getFileStream(this.pdfInfo.node.id, 'arraybuffer').then(response => {
        const binaryData = [];
        binaryData.push(response);
        this.pdfData = window.URL.createObjectURL(new Blob(binaryData, {type: 'application/pdf'}));
      })
    },
    cancel() {
      this.$emit("cancel")
    }
  }
}
</script>

<style scoped>

</style>
